package com.imti.controller;

import cn.hutool.core.util.ObjectUtil;
import com.imti.api.CommonPage;
import com.imti.api.CommonResult;
import com.imti.bean.Card;
import com.imti.bean.dto.LoginDTO;
import com.imti.service.AccountService;
import com.imti.service.CardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author T470S
 * 账号接口
 */
@RestController
@Slf4j
@RequestMapping("/account")
@Api(value = "账号接口")
public class AccountController {

    @Resource
    private AccountService accountService;

    @Resource
    private CardService cardService;

    @GetMapping("/getAccountInfo")
    @ApiOperation("个人信息查询")
    public CommonResult getAccountInfo(@RequestParam(value = "accId", required = true) Integer accId){

        if (ObjectUtil.isNull(accId)){
            return CommonResult.failed();
        }

        List<Card> accountInfo = null;
        System.out.println(accountInfo);
        return CommonResult.success(CommonPage.restPage(accountInfo));
    }

    /**
     * 登录
     * @param loginDTO
     * @return
     */
    @PostMapping("/login")
    @ApiOperation("登录")
    public CommonResult systemLogin(@RequestBody LoginDTO loginDTO){

        if (ObjectUtil.isNull(loginDTO)){
            return CommonResult.failed();
        }


        Map<String, Object> login = accountService.login(loginDTO);
        System.out.println(login);
        return CommonResult.success(login);
    }
}
